package es

import (
	"github.com/olivere/elastic/v7"
)

// https://www.cnblogs.com/wangzhuxing/p/9574630.html
// 纠错补全，输入错误的情况下补全正确的单词
func (m *Model) TermSuggester(name, text, field string) *Model {
	return m.Suggester(name, elastic.NewTermSuggester(name).Text(text).Field(field))
}

// 自动补全短语，输入一个单词补全整个短语
func (m *Model) PhraseSuggester(name, text, field string) *Model {
	return m.Suggester(name, elastic.NewPhraseSuggester(name).Text(text).Field(field))
}

// 完成补全单词，输出如前半部分，补全整个单词
func (m *Model) CompletionSuggester(name, text, field string) *Model {
	return m.Suggester(name, elastic.NewCompletionSuggester(name).Text(text).Field(field))
}

// 上下文补全
func (m *Model) ContextSuggester(name, prefix, field string) *Model {
	return m.Suggester(name, elastic.NewContextSuggester(name).Prefix(prefix).Field(field))
}